/*

Input: Stats on special voting arrangements around the world, IDEA, November 2023
	> cleaned_IDEA_postal_voting_data.xlsx [IDEA, postal voting arrangements]
	> cleaned_IDEA_early_voting_data.xlsx [IDEA, early voting arrangements]

	Download data at:
	https://www.idea.int/data-tools/tools/special-voting-arrangements/postal-in-country 
		[accessed: November 2023]
	
Task: compute stats on prevalence of early voting and postal voting arrangements 
		across countries

*/	
	
* READ: postal voting stats, IDEA
import excel  "$rawdata/IDEA/cleaned_IDEA_postal_voting_data.xlsx", clear firstrow
	
	ren Country				country
	ren Available 			postal 
	ren Whoiseligible		ps_who
	ren Whatisthetimeframe 	ps_time
	ren  LawSources 		ps_law
	ren Notes				ps_notes
	
	encoder democracy, replace
	lab var democracy "Economist Intelligence Unit Demo class"
	
	gen 	ipostal = (postal=="Yes; all voters")
	lab var ipostal "=1 if postal v avlb. to all voters"

	
	tempfile postal
	save `postal'
	
* READ: early voting stats, IDEA
import excel  "$rawdata/IDEA/cleaned_IDEA_early_voting_data.xlsx", clear firstrow
	
	ren Country				country
	ren Available 			early
	ren Whoiseligible		ev_who
	ren Whatisthetimeframe 	ev_time
	ren  LawSource 		ev_law
	ren Notes				ev_notes
	
	gen 	iearly = (early=="Yes; all voters")
	lab var iearly "=1 if early v avlb. to all voters"	
	
	merge 1:1 country using `postal', assert(3) nogen
	
	
	// either postal or early 
	gen either = (ipostal==1|iearly==1)
	
** Stats: 204 countries, 28 OECD, 27 EU
 
// global 
 fre postal 	// 5.9% universal
 fre early		// 7.8% universal
 
//oecd
fre ipostal if oecd==1		// 29% universal 
fre iearly if oecd==1		// 34%

//eu
fre ipostal if eu==1	// 14.8% universal 
fre iearly if eu==1		// 25.9% universal

tab either				// 11.3% 
tab either if oecd==1		// 50% 
tab either if eu==1			// 37%
